package com.wwj.core.system.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wwj.core.system.entity.Parameter;
import com.wwj.core.system.entity.mapper.ParameterMapper;
import com.wwj.core.system.service.IParameterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created by xya on 16-10-24.
 */
@Service
public class ParameterServiceImpl implements IParameterService {

    @Resource
    private ParameterMapper parameterMapper;

    @Override
    public Page<Parameter> findByPage(int offset, int limit, Map<String, Object> params) {
        PageHelper.offsetPage(offset, limit);
        return (Page<Parameter>) parameterMapper.selectParameters(params);
    }

    @Override
    public void addParameter(Parameter parameter) {
        parameterMapper.insertParameter(parameter);
    }

    @Override
    public void modifyParameter(Parameter parameter) {
        parameterMapper.updateParameter(parameter);
    }

    @Override
    public void deleteById(Integer id) {
        parameterMapper.deleteParameterById(id);
    }

    @Override
    public Parameter findById(Integer id) {
        return parameterMapper.selectParameterById(id);
    }

    @Override
    public Parameter findByCode(String code) {
        return parameterMapper.selectParameterByCode(code);
    }
}
